<script>
var qtd = 0;
var auxPedido = "<?php echo $this->pedido; ?>";

if(!auxPedido)
{
	auxPedido = cod_item;
}
else
{
	//qtd = 1;
}

function listProd()
{
	$.post('<?php echo $this->base; ?>/pedido/list', {cod: <?php echo $this->pedido; ?>}, function(req){
		$("#listProd").html(req);
	});
}

function getSubGroup(idMenu)
{
	$("#lisSubgroup div").css("background-color", "").css("color", "black");
	
	$("#divsub_" + idMenu).css("background-color", "#FF9900").css("color", "white");
	
	$("#subgroups").val(idMenu);
	
	$("#load_subproduct").show();

	if(!edpedido)
	{
		edpedido = 0;
	}	
	
	$.post('<?php echo $this->base; ?>/product/subproducts', {cod_menu: idMenu, gerente: auxJson.caf01_admin, cod: auxPedido, pedido: edpedido}, function(req){
		$("#products").html(req);
	});
	
	/*$.getJSON('<?php echo $this->base; ?>/product/jsonproducts', {cod_menu: idMenu}, function(json){
		(json[0].caf04_cod_prod);
	});*/
}

function showIngredientes()
{
	$.post('<?php echo $this->base; ?>/product/ingredientes', {}, function(res){
		$("#ingred").html(res);
	});
}

function setPedido()
{
	if(!qtd)
	{
		msg({vmsg: "Nada modificado.",time: 3000});

		//return;
	}
	else
	{
		msg({vmsg: "Salvo com sucesso.",time: 3000});
	}
	//$("#msg").html("Salvo com sucesso.").fadeIn("fast");
	//setTimeout(function(obj) { $("#msg").fadeOut(); }, 3000, this);

	//window.open("<?php echo $this->base; ?>/imprimir/imprvar/menu/1/cod/" + auxPedido, "_blank");
	//window.open("<?php echo $this->base; ?>/imprimir/imprvar/menu/2/cod/" + auxPedido, "_blank");
	
	pedido = false;

	$(".menu_cnew").click();
}

$(function(){
	getSubGroup(1);

	listProd();
});

</script>

<div style="margin: 0 auto; width: 1110px;">
	
	<input type="hidden" id="subgroups" value="" />
	
	<div id="lisSubgroup" style="float: left; border: 1px solid #B0ADAD; width: 200px;" class="ui-corner-all">
		<div style="height: 3px;"></div>
		<?php 
		foreach ($this->arr_menu as $key => $val)
		{
		?>
		<div id="divsub_<?php echo $key; ?>" onclick="getSubGroup(<?php echo $key; ?>);" style="font-size: 28px; padding: 5px; border-bottom: 1px solid #CFCFCF">
			<?php echo $val; ?>
		</div>
		<?php 
		}
		?>
	</div>
	
	<div id="products" style="float: left; height: 373px; border: 1px solid green; margin-left: 20px; padding: 10px; width: 570px;" class="ui-widget ui-corner-all">
		<img src='<?php echo $this->base; ?>/public/images/ajax-loader.gif' /> Carregando
	</div>
	<div style="float: left; border: 1px solid #B0ADAD; margin-left: 20px; padding: 10px; width: 250px; max-height: 370px; overflow: auto;" class="ui-widget ui-corner-all">
		<div class="button ui-corner-all" onclick="setPedido();" style="padding: 15px; text-align: center; font-weight: bold;" >
			Salvar Pedido
		</div>
		<div class="button ui-corner-all" onclick="voltar();" style="padding: 15px; margin-top: 10px; text-align: center; font-weight: bold;" >
			Voltar
		</div>
		<hr style="margin: 10px 0 10px 0;" />
		<div id="listProd">
			
		</div>
	</div>
	<div style="float: left; border: 1px solid #B0ADAD; margin-left: 20px; padding: 10px; width: 250px; max-height: 370px; overflow: auto;">
		<button class="button" style="font-size: 15px; padding: 3px; width: 100%; text-align: center;" onclick="showIngredientes();">
			Ingred.
		</button>
		<button class="button" style="font-size: 15px; padding: 3px;">
			Modos
		</button>
		<button class="button" style="font-size: 15px; padding: 3px;">
			Acompan.
		</button>
	</div>
</div>